package com.zmn.plat.services.impl.channel.promotion;

import com.zmn.common.dto.StatusDTO;
import com.zmn.common.utils.date.DateUtil;
import com.zmn.plat.model.entity.channel.promotion.ChannelPromotion;
import com.zmn.plat.model.entity.channel.promotion.ChannelPromotionQuery;
import com.zmn.plat.persistence.interfaces.channel.promotion.ChannelPromotionDao;
import com.zmn.plat.services.interfaces.channel.promotion.ChannelPromotionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 渠道推广配置实现类(当前只有今日头条使用)
 *
 * @author linfeng
 *
 * @since 2020/11/20 17:03
 */
@Service
public class ChannelPromotionServiceImpl implements ChannelPromotionService {

    @Resource
    ChannelPromotionDao channelPromotionDao;

    @Override
    public ChannelPromotion findByKey(Integer relateId) {
        return channelPromotionDao.findByKey(relateId);
    }

    @Override
    public List<ChannelPromotion> listPageByQuery(ChannelPromotionQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return channelPromotionDao.listPageByQuery(query);
    }

    @Override
    public List<ChannelPromotion> listByQuery(ChannelPromotionQuery query) {
        return channelPromotionDao.listByQuery(query);
    }

    @Override
    public List<ChannelPromotion> listByRelateIds(List<Integer> list) {
        return channelPromotionDao.listByRelateIds(list);
    }

    @Override
    public List<ChannelPromotion> listAll() {
        return channelPromotionDao.listAll();
    }

    @Override
    public Integer countByQuery(ChannelPromotionQuery query) {
        return channelPromotionDao.countByQuery(query);
    }
    @Override
    public Integer updateStatusByKey(ChannelPromotion channelPromotion) {
        return channelPromotionDao.updateStatusByKey(channelPromotion);
    }

    @Override
    public Integer updateStatusBatch(List<Integer> ids, Integer status, String mcStaffName) {
        StatusDTO dto = new StatusDTO();
        dto.setIds(ids);
        dto.setStatus(status);
        dto.setUpdater(mcStaffName);
        dto.setUpdateTime(DateUtil.getNow());
        return channelPromotionDao.updateBatchStatus(dto);
    }
    @Override
    public Integer updateByKey(ChannelPromotion channelPromotion) {
        return channelPromotionDao.updateByKey(channelPromotion);
    }

    @Override
    public Integer insert(ChannelPromotion channelPromotion) {
        return channelPromotionDao.insert(channelPromotion);
    }

    @Override
    public Integer deleteByKey(Integer relateId) {
        return channelPromotionDao.deleteByKey(relateId);
    }

}